import { wxRequest } from '../../utils/server.js';
const _wxRequest = new wxRequest();
const app = getApp()
Page({

  data: {
    detail: {},
    stepsList: []
  },

  onLoad: function (options) {
    if (options.id) {
      this.setData({
        id: options.id,
      })
      this.getdetail()
    }
  },

  onShow: function () {

  },


  //获取详情
  getdetail: function () {
    _wxRequest.wxTonkenAjax({
      url: app.globalData.apiUrl + '/odr/protected/order/detail?id=' + this.data.id,
      method: 'POST',
    }, (res) => {
      var resVo = res.vo
      this.setData({
        detail: resVo
      })
      this.logisticsTrace()
    })
  },


  //快递信息查询 
  logisticsTrace: function (params) {
    _wxRequest.wxTonkenAjax({
      url: app.globalData.apiUrl + '/odr/protected/logistics/trace?shipperCode=' + this.data.detail.shipperCode + '&expNo=' + this.data.detail.expressNo,
      method: 'POST',
      data: params
    }, (res) => {

      var list = res.list

      list.sort(function (a, b) {
        return b.acceptTime > a.acceptTime;
      })
      this.setData({
        stepsList: list
      })
    })
  }


})